Skip to content

[diffs] CodeView Layout & Options Optimizations#718

Merged
amadeus merged 13 commits into
mainfrom
amadeus/cache-estimated-heights
May 22, 2026
Merged

[diffs] CodeView Layout & Options Optimizations#718
amadeus merged 13 commits into
mainfrom
amadeus/cache-estimated-heights

Conversation

@amadeus
Copy link
Copy Markdown
Member

@amadeus amadeus commented May 20, 2026

Went a bit deep on optimizing option and layout changes, especially in more pathological that involved moving from split to unified. These are both performance and memory optimizations.

  • Per item layouts are now estimated much faster than before
  • Options are not longer fully duplicated for each instance, and instead use a shared accessor object to pull stuff off as needed.
    • This removes the need for option changes requiring every instance to update (they can now just access a shared top level object on codeview to pull the updated date from
  • Fixed a bug where CodeView wouldn't clear the element pool when themes change
  • Fixed an older regression where no-newlines weren't rendered correctly

Results

I would share a video but it's too big for github. Some approximate numbers, the linux diff used to take around 200-300ms when toggling between split and unified. Now it should be sub 40ms. Stilll not as fast as I would like, but usable. Also memory usage i think dropped by 50-100mb in the extreme linux variant with the new shared options logic.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffshub Ready Ready Preview May 22, 2026 10:24pm
pierre-docs-trees Ready Ready Preview May 22, 2026 10:24pm
pierrejs-diff-demo Ready Ready Preview May 22, 2026 10:24pm
pierrejs-docs Ready Ready Preview May 22, 2026 10:24pm

Request Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d60fd50625

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@amadeus amadeus force-pushed the amadeus/cache-estimated-heights branch from d60fd50 to 088df82 Compare May 20, 2026 08:21
@amadeus amadeus force-pushed the amadeus/cache-estimated-heights branch from 088df82 to 45a508d Compare May 20, 2026 08:27
Base automatically changed from beta-1.2 to main May 20, 2026 18:43
@amadeus amadeus force-pushed the amadeus/cache-estimated-heights branch from 45a508d to e730f08 Compare May 21, 2026 00:23
amadeus added 6 commits May 21, 2026 18:21
Create small reusable utilities for the estimate helper and existing virtual
layout code.

- Extract or share the `getExpandedRegion` logic currently inside
  `iterateOverDiff` so expansion math cannot drift.
- Add a separator estimate helper that mirrors renderer/CSS behavior.
- Keep these helpers pure and independent of `VirtualizedFileDiff`
  instance state.

Separator helper rules:

- `simple`: render only when `hunkIndex > 0`; height is
  `metrics.hunkSeparatorHeight ?? 4`.
- `metadata`: render only when `hunkSpecs != null`; height is
  `metrics.hunkSeparatorHeight ?? 32`.
- `line-info-basic`: height is `metrics.hunkSeparatorHeight ?? 32`.
- `line-info`: height is `metrics.hunkSeparatorHeight ?? 32`, plus
  top/bottom spacing based on first/last position.
- `line-info`: omit top gap for `isFirstHunk`.
- `line-info`: omit bottom gap for `isLastHunk`.
- `custom`: estimate like `line-info` unless we decide to force custom
  separators to be measurement-only later.
@amadeus
Copy link
Copy Markdown
Member Author

amadeus commented May 22, 2026

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a60b37fbb3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/diffs/src/components/CodeView.ts
Comment thread packages/diffs/src/utils/computeEstimatedDiffHeights.ts Outdated
@amadeus
Copy link
Copy Markdown
Member Author

amadeus commented May 22, 2026

@codex review

@amadeus amadeus merged commit 19e899c into main May 22, 2026
12 checks passed
@amadeus amadeus deleted the amadeus/cache-estimated-heights branch May 22, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant